import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/list_ledger_entity.dart';

ListLedgerEntity $ListLedgerEntityFromJson(Map<String, dynamic> json) {
  final ListLedgerEntity listLedgerEntity = ListLedgerEntity();
  final String? countId = jsonConvert.convert<String>(json['countId']);
  if (countId != null) {
    listLedgerEntity.countId = countId;
  }
  final int? current = jsonConvert.convert<int>(json['current']);
  if (current != null) {
    listLedgerEntity.current = current;
  }
  final int? maxLimit = jsonConvert.convert<int>(json['maxLimit']);
  if (maxLimit != null) {
    listLedgerEntity.maxLimit = maxLimit;
  }
  final bool? optimizeCountSql = jsonConvert.convert<bool>(json['optimizeCountSql']);
  if (optimizeCountSql != null) {
    listLedgerEntity.optimizeCountSql = optimizeCountSql;
  }
  final List<ListLedgerOrders>? orders = (json['orders'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ListLedgerOrders>(e) as ListLedgerOrders).toList();
  if (orders != null) {
    listLedgerEntity.orders = orders;
  }
  final int? pages = jsonConvert.convert<int>(json['pages']);
  if (pages != null) {
    listLedgerEntity.pages = pages;
  }
  final List<ListLedgerRecords>? records = (json['records'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ListLedgerRecords>(e) as ListLedgerRecords).toList();
  if (records != null) {
    listLedgerEntity.records = records;
  }
  final bool? searchCount = jsonConvert.convert<bool>(json['searchCount']);
  if (searchCount != null) {
    listLedgerEntity.searchCount = searchCount;
  }
  final int? size = jsonConvert.convert<int>(json['size']);
  if (size != null) {
    listLedgerEntity.size = size;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    listLedgerEntity.total = total;
  }
  return listLedgerEntity;
}

Map<String, dynamic> $ListLedgerEntityToJson(ListLedgerEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['countId'] = entity.countId;
  data['current'] = entity.current;
  data['maxLimit'] = entity.maxLimit;
  data['optimizeCountSql'] = entity.optimizeCountSql;
  data['orders'] = entity.orders?.map((v) => v.toJson()).toList();
  data['pages'] = entity.pages;
  data['records'] = entity.records?.map((v) => v.toJson()).toList();
  data['searchCount'] = entity.searchCount;
  data['size'] = entity.size;
  data['total'] = entity.total;
  return data;
}

extension ListLedgerEntityExtension on ListLedgerEntity {
  ListLedgerEntity copyWith({
    String? countId,
    int? current,
    int? maxLimit,
    bool? optimizeCountSql,
    List<ListLedgerOrders>? orders,
    int? pages,
    List<ListLedgerRecords>? records,
    bool? searchCount,
    int? size,
    int? total,
  }) {
    return ListLedgerEntity()
      ..countId = countId ?? this.countId
      ..current = current ?? this.current
      ..maxLimit = maxLimit ?? this.maxLimit
      ..optimizeCountSql = optimizeCountSql ?? this.optimizeCountSql
      ..orders = orders ?? this.orders
      ..pages = pages ?? this.pages
      ..records = records ?? this.records
      ..searchCount = searchCount ?? this.searchCount
      ..size = size ?? this.size
      ..total = total ?? this.total;
  }
}

ListLedgerOrders $ListLedgerOrdersFromJson(Map<String, dynamic> json) {
  final ListLedgerOrders listLedgerOrders = ListLedgerOrders();
  final bool? asc = jsonConvert.convert<bool>(json['asc']);
  if (asc != null) {
    listLedgerOrders.asc = asc;
  }
  final String? column = jsonConvert.convert<String>(json['column']);
  if (column != null) {
    listLedgerOrders.column = column;
  }
  return listLedgerOrders;
}

Map<String, dynamic> $ListLedgerOrdersToJson(ListLedgerOrders entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['asc'] = entity.asc;
  data['column'] = entity.column;
  return data;
}

extension ListLedgerOrdersExtension on ListLedgerOrders {
  ListLedgerOrders copyWith({
    bool? asc,
    String? column,
  }) {
    return ListLedgerOrders()
      ..asc = asc ?? this.asc
      ..column = column ?? this.column;
  }
}

ListLedgerRecords $ListLedgerRecordsFromJson(Map<String, dynamic> json) {
  final ListLedgerRecords listLedgerRecords = ListLedgerRecords();
  final String? checkAcceptPerson = jsonConvert.convert<String>(json['checkAcceptPerson']);
  if (checkAcceptPerson != null) {
    listLedgerRecords.checkAcceptPerson = checkAcceptPerson;
  }
  final String? checkAcceptTime = jsonConvert.convert<String>(json['checkAcceptTime']);
  if (checkAcceptTime != null) {
    listLedgerRecords.checkAcceptTime = checkAcceptTime;
  }
  final String? dangerLevel = jsonConvert.convert<String>(json['dangerLevel']);
  if (dangerLevel != null) {
    listLedgerRecords.dangerLevel = dangerLevel;
  }
  final String? dangerManageDeadline = jsonConvert.convert<String>(json['dangerManageDeadline']);
  if (dangerManageDeadline != null) {
    listLedgerRecords.dangerManageDeadline = dangerManageDeadline;
  }
  final String? dangerManageType = jsonConvert.convert<String>(json['dangerManageType']);
  if (dangerManageType != null) {
    listLedgerRecords.dangerManageType = dangerManageType;
  }
  final String? dangerName = jsonConvert.convert<String>(json['dangerName']);
  if (dangerName != null) {
    listLedgerRecords.dangerName = dangerName;
  }
  final String? dangerSrc = jsonConvert.convert<String>(json['dangerSrc']);
  if (dangerSrc != null) {
    listLedgerRecords.dangerSrc = dangerSrc;
  }
  final String? dangerState = jsonConvert.convert<String>(json['dangerState']);
  if (dangerState != null) {
    listLedgerRecords.dangerState = dangerState;
  }
  final String? hazardCategory = jsonConvert.convert<String>(json['hazardCategory']);
  if (hazardCategory != null) {
    listLedgerRecords.hazardCategory = hazardCategory;
  }
  final String? hazardDangerType = jsonConvert.convert<String>(json['hazardDangerType']);
  if (hazardDangerType != null) {
    listLedgerRecords.hazardDangerType = hazardDangerType;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    listLedgerRecords.id = id;
  }
  final String? liablePerson = jsonConvert.convert<String>(json['liablePerson']);
  if (liablePerson != null) {
    listLedgerRecords.liablePerson = liablePerson;
  }
  final String? registTime = jsonConvert.convert<String>(json['registTime']);
  if (registTime != null) {
    listLedgerRecords.registTime = registTime;
  }
  final String? registrant = jsonConvert.convert<String>(json['registrant']);
  if (registrant != null) {
    listLedgerRecords.registrant = registrant;
  }
  final String? riskEventName = jsonConvert.convert<String>(json['riskEventName']);
  if (riskEventName != null) {
    listLedgerRecords.riskEventName = riskEventName;
  }
  final String? riskMeasureDesc = jsonConvert.convert<String>(json['riskMeasureDesc']);
  if (riskMeasureDesc != null) {
    listLedgerRecords.riskMeasureDesc = riskMeasureDesc;
  }
  final String? riskObjectName = jsonConvert.convert<String>(json['riskObjectName']);
  if (riskObjectName != null) {
    listLedgerRecords.riskObjectName = riskObjectName;
  }
  final String? riskUnitName = jsonConvert.convert<String>(json['riskUnitName']);
  if (riskUnitName != null) {
    listLedgerRecords.riskUnitName = riskUnitName;
  }
  return listLedgerRecords;
}

Map<String, dynamic> $ListLedgerRecordsToJson(ListLedgerRecords entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['checkAcceptPerson'] = entity.checkAcceptPerson;
  data['checkAcceptTime'] = entity.checkAcceptTime;
  data['dangerLevel'] = entity.dangerLevel;
  data['dangerManageDeadline'] = entity.dangerManageDeadline;
  data['dangerManageType'] = entity.dangerManageType;
  data['dangerName'] = entity.dangerName;
  data['dangerSrc'] = entity.dangerSrc;
  data['dangerState'] = entity.dangerState;
  data['hazardCategory'] = entity.hazardCategory;
  data['hazardDangerType'] = entity.hazardDangerType;
  data['id'] = entity.id;
  data['liablePerson'] = entity.liablePerson;
  data['registTime'] = entity.registTime;
  data['registrant'] = entity.registrant;
  data['riskEventName'] = entity.riskEventName;
  data['riskMeasureDesc'] = entity.riskMeasureDesc;
  data['riskObjectName'] = entity.riskObjectName;
  data['riskUnitName'] = entity.riskUnitName;
  return data;
}

extension ListLedgerRecordsExtension on ListLedgerRecords {
  ListLedgerRecords copyWith({
    String? checkAcceptPerson,
    String? checkAcceptTime,
    String? dangerLevel,
    String? dangerManageDeadline,
    String? dangerManageType,
    String? dangerName,
    String? dangerSrc,
    String? dangerState,
    String? hazardCategory,
    String? hazardDangerType,
    String? id,
    String? liablePerson,
    String? registTime,
    String? registrant,
    String? riskEventName,
    String? riskMeasureDesc,
    String? riskObjectName,
    String? riskUnitName,
  }) {
    return ListLedgerRecords()
      ..checkAcceptPerson = checkAcceptPerson ?? this.checkAcceptPerson
      ..checkAcceptTime = checkAcceptTime ?? this.checkAcceptTime
      ..dangerLevel = dangerLevel ?? this.dangerLevel
      ..dangerManageDeadline = dangerManageDeadline ?? this.dangerManageDeadline
      ..dangerManageType = dangerManageType ?? this.dangerManageType
      ..dangerName = dangerName ?? this.dangerName
      ..dangerSrc = dangerSrc ?? this.dangerSrc
      ..dangerState = dangerState ?? this.dangerState
      ..hazardCategory = hazardCategory ?? this.hazardCategory
      ..hazardDangerType = hazardDangerType ?? this.hazardDangerType
      ..id = id ?? this.id
      ..liablePerson = liablePerson ?? this.liablePerson
      ..registTime = registTime ?? this.registTime
      ..registrant = registrant ?? this.registrant
      ..riskEventName = riskEventName ?? this.riskEventName
      ..riskMeasureDesc = riskMeasureDesc ?? this.riskMeasureDesc
      ..riskObjectName = riskObjectName ?? this.riskObjectName
      ..riskUnitName = riskUnitName ?? this.riskUnitName;
  }
}
